package com.wf.day_0603.test1;

import java.util.HashSet;

/**
 * @author mpk
 * @since 2024/6/3 16:56:16
 */

// set作业：
// 练习1：求一个字符串"aiodjl;hriWFUADJSV123UEHiowfjnivowe"中一共有几个不重复的字母,区分大小写,如a,A算两个字符 （HashSet）

public class Demo {
    public static void main(String[] args) {


        String s="aiodjl;hriWFUADJSV123UEHiowfjnivowe";


        System.out.println(notRepeatCount(s));
    }

    private static int notRepeatCount(String s) {


        HashSet<Character> character1 = new HashSet<>();
        HashSet<Character> character2 = new HashSet<>();



        for (int i = 0; i < s.length(); i++) {

           if(s.substring(i, i + 1).matches("[a-zA-Z]"))
           {
               if(!character1.add(s.charAt(i)))
               {
                   character2.add(s.charAt(i));
               }

           }

        }

        return character1.size()-character2.size();





    }


}
